const fp = require('lodash/fp');

class IO {
  static of(value) {
    return new IO(function () {
      return value;
    })
  }
  constructor(fn) {
    this._value = fn;
  }

  map(fn) {
    return new IO(fp.flowRight(fn, this._value));
  }
}

let a = IO.of(process).map(p => p.execPath);// 传入有可能不纯，返回是纯操作

console.log(a);
console.log(a._value())